class Solution:

    def addStrings(self, num1: str, num2: str) -> str:
        ans = []
        n1, n2, c = len(num1) - 1, len(num2) - 1, 0
        while n1 >= 0 or n2 >= 0 or c > 0:
            if n1 >= 0:
                c += ord(num1[n1]) - ord('0')
                n1 -= 1
            if n2 >= 0:
                c += ord(num2[n2]) - ord('0')
                n2 -= 1
            ans.append(chr(c % 10 + ord('0')))
            c //= 10
        return "".join(ans)[-1::-1]


class Solution:

    def addStrings(self, num1: str, num2: str) -> str:
        ans = []
        n1, n2, c = len(num1) - 1, len(num2) - 1, 0
        while n1 >= 0 or n2 >= 0 or c > 0:
            if n1 >= 0:
                c += int(num1[n1])
                n1 -= 1
            if n2 >= 0:
                c += int(num2[n2])
                n2 -= 1
            ans.append(str(c % 10))
            c //= 10
        return "".join(ans)[-1::-1]

s = Solution()
print(s.addStrings(num1="11", num2="123"))